import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class DioCase extends StatelessWidget {
  const DioCase({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          GestureDetector(
            child: const Text('发送网络请求'),
            onTap: () async {
              print('被点击了');
              final dio = Dio();
              var res = await dio.get('https://geek.itheima.net/v1_0/channels');
              print(res.data);
            },
          ),
          ElevatedButton(
              onPressed: () async {
                final dio = Dio();
                var res =
                    await dio.get('https://geek.itheima.net/v1_0/channels');
                print(res.data);
              },
              child: const Text('发送网络请求'))
        ],
      ),
    );
  }
}
